using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
using System;

public static class SceneUtil 
{
    public static Task WaitCompleteAsync(MonoBehaviour runner, AsyncOperation oper)
    {
        var tcs = new TaskCompletionSource<bool>();
        runner.StartCoroutine(_InsterWaitCompleteAsync(oper, () =>
        {
            tcs.SetResult(true);
        }));
        return tcs.Task;
    }

    public static IEnumerator _InsterWaitCompleteAsync(AsyncOperation oper, Action compelte)
    {
        yield return oper;
        compelte?.Invoke();
    }
}
